/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package entidades;

import java.io.Serializable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 *
 * @author Andres
 */
@Entity
@Table(name = "RESERVAHOTEL", catalog = "", schema = "PROYECTO", uniqueConstraints = {
    @UniqueConstraint(columnNames = {"CONF_PERSONA_CODPE"})})
@NamedQueries({
    @NamedQuery(name = "Reservahotel.findAll", query = "SELECT r FROM Reservahotel r"),
    @NamedQuery(name = "Reservahotel.findByReservaCodigoreserva", query = "SELECT r FROM Reservahotel r WHERE r.reservahotelPK.reservaCodigoreserva = :reservaCodigoreserva"),
    @NamedQuery(name = "Reservahotel.findByConfPersonaCodpe", query = "SELECT r FROM Reservahotel r WHERE r.reservahotelPK.confPersonaCodpe = :confPersonaCodpe")})
public class Reservahotel implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected ReservahotelPK reservahotelPK;
    @JoinColumn(name = "RESERVA_CODIGORESERVA", referencedColumnName = "CODIGORESERVA", nullable = false, insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Reserva reserva;

    public Reservahotel() {
    }

    public Reservahotel(ReservahotelPK reservahotelPK) {
        this.reservahotelPK = reservahotelPK;
    }

    public Reservahotel(int reservaCodigoreserva, int confPersonaCodpe) {
        this.reservahotelPK = new ReservahotelPK(reservaCodigoreserva, confPersonaCodpe);
    }

    public ReservahotelPK getReservahotelPK() {
        return reservahotelPK;
    }

    public void setReservahotelPK(ReservahotelPK reservahotelPK) {
        this.reservahotelPK = reservahotelPK;
    }

    public Reserva getReserva() {
        return reserva;
    }

    public void setReserva(Reserva reserva) {
        this.reserva = reserva;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (reservahotelPK != null ? reservahotelPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Reservahotel)) {
            return false;
        }
        Reservahotel other = (Reservahotel) object;
        if ((this.reservahotelPK == null && other.reservahotelPK != null) || (this.reservahotelPK != null && !this.reservahotelPK.equals(other.reservahotelPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidades.Reservahotel[reservahotelPK=" + reservahotelPK + "]";
    }

}
